package com.jyh.controller;


import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.jyh.config.redis.JedisClient;
import com.jyh.service.LoginService;

/**
 * Created by Administrator on 2017/3/1 14:55.
 */
@Controller
public class TestController {
	protected final Logger logger = LoggerFactory.getLogger(this.getClass());
	@Autowired
	private JedisClient jedisClientPool;
	@Autowired
	private LoginService loginService;
	
	
	// 添加
	@RequestMapping(value = "/add", method = RequestMethod.GET)
	@ResponseBody
	public void test() {
		System.out.println("start.....");
		String key = "repayment_entrust_key_" + "111111";
		// 获取
		String string = jedisClientPool.get(key);
		if (string != null) {
			System.out.println("已经在处理中，请稍后。");
		}
		// 插入
		jedisClientPool.set(key, "1");

	}

	

	// 删除
	@RequestMapping(value = "/remove", method = RequestMethod.GET)
	@ResponseBody
	public void remove() {
		// 删除KEY
		String key = "repayment_entrust_key_" + "111111";
		jedisClientPool.del(key);
		System.out.println("add success end...");
	}

	@RequestMapping("/test1")
	public ModelAndView page1(String str,HttpServletRequest request,HttpSession session){
		// 页面位置 /WEB-INF/jsp/page/page.jsp
		loginService.getTransition("11",request, session);
		ModelAndView mav = new ModelAndView(str);
		return mav;
	}
	
	
	@RequestMapping("/test2")
	public ModelAndView page2(ModelAndView mav){
		mav.setViewName("aaa");
		return mav;
	}
	
    @RequestMapping("/test3")  
    public String welcome(Map<String, Object> model) {  
        return "aaa";  
    }  
	
}